<template>
  <div>
    <el-table :data="tableData" :show-header="false" style="width: 100%;margin-top: 15px;" height="100" :header-cell-style="headerCellStyle" :cell-style="cellStyle">
      <template slot="empty">
        <p>暂无推屏</p>
      </template>
      <el-table-column prop="id" align="center" label="序号" min-width="10%">
      </el-table-column>
      <el-table-column prop="groupNumber" align="center" label="无聊群ID" min-width="20%">
      </el-table-column>
      <el-table-column prop="name" :show-overflow-tooltip="true" align="center" label="无聊群名称" min-width="50%">
      </el-table-column>
      <el-table-column prop="personNum" :show-overflow-tooltip="true" align="center" label="无聊群人数" min-width="20%">
      </el-table-column>
      <el-table-column prop="status" :show-overflow-tooltip="true" align="center" label="状态" min-width="10%">
        <template slot-scope="scope">
          <span v-if="scope.row.status==0" style="color:red;">未推送</span>
          <span v-if="scope.row.status==1" style="color:green;">推送中</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
  export default {
    name: "liveControllerGroupPushScreen",
    components: {
    },
    props:{
      data:{
        type: Object,
        default:()=>{}
      }
    },
    data() {
      return {
        headerCellStyle:{
          'background-color': '#f1f1f1',
          'font-size':'12px',
          'color':'#000000'
        },
        cellStyle:{
          'font-size':'12px',
          'border-bottom':'0'
        },
        tableData:[],
      }
    },
    mounted: function () {
      this.parentData = this.data
      this.getData()
      this.init();
    },
    destroyed(){ // 页面销毁
      this.clearTimer()
    },
    methods: {
      clearTimer(){ // 清除定时器
        clearInterval(this.timer)
      },
      init() {
        let i=0;
        this.timer = setInterval(() => {
          this.tableData.forEach((item,idx) => {
            if(item.status==1 && item.downTime<=0){
              this.getData();
            }
            item.downTime--;
          })
          if(i==5){
            this.getData();
            i=-1;
          }
          i++;
        },1000)
      },
      pushScreen(row){
        this.getData();
      },
      getData(){
        this.utils.request.liveRequest({
          url: '/api/v1/boring/push/'+this.parentData.id,
          method: 'get'
        }).then(result => {
          let data = result.data;
          if (data && data.code === '0') {
            this.tableData = data.data;
          }
        })
      }
    }
  }
</script>
<style scoped lang="scss">

</style>
